In [1]:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import numpy as np
from IPython.display import display, Math, Latex
import pylab
import itertools
import plot_methods
import optimization_methods
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
In [2]:
my_function = lambda x, y, z: 16*x**2 + 15*y**2 + 2*z**2 + 0.018*x*y + x-z
In [3]:
result = optimization_methods.conjucate_gradients_method(func=my_function, params=[1,1,1], eps=1e-5,
                                                        start=0, end=1, quadratic=False)
number of iteration: 2, current point: [ 0.02723464 -0.07409267  0.64556502], function value: 0.3093551596052133
number of iteration: 3, current point: [-3.12305912e-02  8.83946842e-07  2.49943486e-01], function value: -0.14062498807023854
number of iteration: 4, current point: [-3.12518505e-02  1.92185807e-05  2.49951212e-01], function value: -0.14062500045542692
number of iteration: 5, current point: [-3.12470140e-02  2.27603796e-05  2.49994905e-01], function value: -0.14062500483638213
number of iteration: 6, current point: [-3.12500111e-02  1.87491155e-05  2.50000004e-01], function value: -0.14062500527343924
Precision: 7.146569262121282e-06
In [4]:
plot_methods.plot_implicit(fn=my_function, bbox=(-0.01, 0.01))
In [5]:
func = lambda x, y: x**2 + 4*y**2 + 0.001*x*y - y
In [ ]:
plot_methods.plot_function([func], 'Quadratic function')
In [ ]: